<div class="row">
	<div class="col-md-12">
		<ol class="breadcrumb">
			<li>
				<a href="#" onclick="toHome()">
					主页
				</a>
			</li>
			<li class="active">
				数据更新
			</li>
		</ol>
	</div>
</div>
<form role="form" class="form-horizontal">
	<div class="row page-cont">
		<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 cont-top">
			<div class="panel panel-white">
				<div class="panel-heading">
					<h4 class="panel-title">
						<span class="title-text">数据更新</span>
					</h4>
					<div class="panel-tools">
						<div class="dropdown">
							<a data-toggle="dropdown" class="btn btn-xs dropdown-toggle btn-transparent-grey">
								<i class="fa fa-cog"></i>
							</a>
							<ul class="dropdown-menu dropdown-light pull-right" role="menu">
								<li>
									<a class="panel-collapse collapses" href="#"><i class="fa fa-angle-up"></i> <span>折叠</span> </a>
								</li>
								<li>
									<a class="panel-expand" href="#">
										<i class="fa fa-expand"></i> <span>全屏</span>
									</a>
								</li>
							</ul>
						</div>
						<a class="btn btn-xs btn-link panel-close" href="#">
							<i class="fa fa-times"></i>
						</a>
					</div>
				</div>
				<div class="panel-body">
					<div class="form-group panel-cont">
					    <div class="col-sm-3">
					    	<button type="button" class="btn btn-green">全量更新主线路&nbsp;<i class="fa fa-arrow-circle-right"></i></button>
					    </div>
					    <div class="col-sm-3">
					    	<button type="button" class="btn btn-red">全量更新备用线路&nbsp;<i class="fa fa-arrow-circle-right"></i></button>
					    </div>
						<div class="col-sm-3">
					   		<button type="button" class="btn btn-purple">排期更新主线路&nbsp;<i class="fa fa-arrow-circle-right"></i></button>
					    </div>
					    <div class="col-sm-3">
					    	<button type="button" id="scheduling-spare" class="btn btn-dark-yellow">排期更新备用线路&nbsp;<i class="fa fa-arrow-circle-right"></i></button>
					    </div>					    
				  	</div>
				</div>
			</div>
		</div>
	</div>
</form>
<script>

	/**********************************************变量**********************************************/
	var username = GetQueryString("username");      // 用户姓名
	var token = MXCookie.get("token",token);  // 登陆token   
	var logCode; // 日志编号

	/**********************************************事件**********************************************/
	// 排期更新备用线路
	$("#scheduling-spare").click(function(){
		schedulingSpare();
	});
	

	/**********************************************函数**********************************************/
	// 排期更新备用线路
	function schedulingSpare(){
		$.ajax({
			url: localStorage.grobalUrl + "/system/standBySchedulesUpdate",
			type: "post",
			data: {
				username: username,
				token: token
			},
			success: function(data){
				console.log(data);
				if(data.errCode == "00005"){
					tips("请重新登陆");
					setTimeout(function(){
						window.location.href = "login_login.html";
					},500);					
				}else if(data.errCode == "00000"){
					logCode = (data.errMsg).split("号")[1];
					getList(logCode);
				}
			},
			error: function(err){
				console.log(err);
			}
		});
		
	}
	

	// 获取更新日志
	function getList(logCode){
		$.ajax({
			url: localStorage.grobalUrl + "/system/updateLogList",
			type:"post",
			data:{
				username: username,
				token: token,
				pageNo: "1",   
				pageCount: "10",
				name: logCode			
			},
			success: function(data){
				console.log(data);
				if(data.errCode == "00005"){
					tips("请重新登陆");
					setTimeout(function(){
						window.location.href = "login_login.html";
					},500);					
				}	
				if (data.logs){
	  				var dataVal = data.logs.list;			
	  				for(var i = 0; i < dataVal.length; i ++){
	  					var listVal = dataVal[i];
	  					if(listVal.is_ok == "1"){
	  						alert("已更新");
	  					}else{
	  						alert("未更新");
	  					}
	  				}		
				}
			},
			error: function(err){
				console.log(err);
			}
		});
	}

	
</script>
